<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<link rel="stylesheet" href="../../../webjars/layui/2.5.6/css/layui.css"
	media="all">
<script src="../../../webjars/layui/2.5.6/layui.all.js" charset="utf-8"></script>
<script src="../../js/vue.min.js"></script>
<script type="text/javascript" src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.0/axios.min.js"></script>
<body >
	<div class="layui-upload">
	  <button type="button" class="layui-btn" id="test2">选择图片</button> 
	  <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
		    预览图：
		    <div class="layui-upload-list" id="demo2"></div>
	 </blockquote>
	 	<div class="site-text">
	      <div class="layui-btn-container">
	        
	        <button id="upload_images" type="button" type="button" class="layui-btn" @click="upload_images()">确认上传</button>
	        
	      </div>
	    </div>
	</div>
	 
 
 <script>
 var v1 = new Vue({
	 el:"#upload_images",
	 data:{
		 account:"",
	 },
	 methods:{
		 upload_images(){
			 axios.get("../../../submit.s").then(function(res){
				 if(res.data.code == 1){
					 alert("上传成功");
					 var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
					 parent.layer.close(index); //再执行关闭
					 
					 
					 
					 
				 }else{
					  alert("上传失败,请联系管理员");
				 }
			 })
		 }
	 }
 });
 
 layui.use(['upload', 'element', 'layer'], function(){
	  var $ = layui.jquery
	  ,upload = layui.upload
	  ,element = layui.element
	  ,layer = layui.layer;
  //多图片上传
  upload.render({
    elem: '#test2'
    ,url: '../../../upload/uploadPortrait.s' //改成您自己的上传接口
    ,multiple: true
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">')
      });
    }
    ,done: function(res){
    	console.info(res);
      //上传完毕
      if(res.code){
    	 
      }else{
    	  alert("此文件无法预览");
      }
    }
  });
});
  
  
  
  
  
 
</script>
</body>
</html>